import axios from "axios";
// import qs from "qs";
// 请求拦截器
axios.interceptors.request.use(
  (config) => {
    console.log('请求拦截器',config)
    // const {method, data } = config
    // 全局修改 请求头
    config.headers.authorization = "bearer token"
    // 全局处理post传参
    // if(method === 'post') {
      // config.data = qs.stringify(data || {})
    // }
    return config
  },
  (error) =>
    // Do something with request error
    Promise.reject(error)
);

// 响应拦截器
axios.interceptors.response.use(
  (response) => {
    console.log('响应拦截器',response)
    return response.data
  },
  (error) =>
    // Any status codes that falls outside the range of 2xx cause this function to trigger
    // Do something with response error
    Promise.reject(error)
);
export default axios;
